﻿using System.Web;
using PmfWeb.Core.Cache;

namespace PmfWeb.Core.HttpHandlers
{
    ///<summary>
    /// 地址重写页面处理器
    ///</summary>
    public class UrlRewriter: IHttpHandler
    {
        ///<summary>
        /// 请求开始被处理时
        ///</summary>
        public void ProcessRequest(HttpContext context)
        {
            string sPath = HttpContext.Current.Request.RawUrl;  //取得原始地址,去掉参数
            RewriteHelper helper = RewriteHelper.Instance();
            string result = helper.GetRewritePath(sPath);

            if (!System.String.IsNullOrEmpty(result) && context != null) context.RewritePath(result);
        }
        /// <summary>
        /// 是否启用缓存
        /// </summary>
        public bool IsReusable
        {
            get { return true;}
        }
    }
}
